package com.omega_r.libs.omegarecyclerview.viewpager.default_transformers;

import ohos.agp.components.Component;

public class DepthPageTransformer extends ABaseTransformer {

    @Override
    protected void onTransform(Component component, float position) {
        if (position <= 0.0F) {
            component.setTranslationX(0.0F);
            component.setScaleX(1.0F);
            component.setScaleY(1.0F);
        } else if (position <= 1.0F) {
            float scaleFactor = 0.75F + 0.25F * ((float)1 - Math.abs(position));
            component.setAlpha((float)1 - position);
            component.setPivotY(0.5F * (float)component.getHeight());
            component.setTranslationX((float)component.getWidth() * -position);
            component.setScaleX(scaleFactor);
            component.setScaleY(scaleFactor);
        }
    }

    @Override
    public boolean isPagingEnabled() {
        return true;
    }
}
